package com.bawei.database.table;

import androidx.room.TypeConverter;

import com.blankj.utilcode.util.GsonUtils;

import java.util.ArrayList;

/**
 * Author: Jason Zhang
 * Date: 2024/4/26
 * Desc: 数据库字段转换，比如将数组转化成字符串，将字符串转化成数组
 */
public class CustomTypeConverters {

    @TypeConverter
    public String arrayListToString(ArrayList<String> data) {
        return GsonUtils.toJson(data);
    }

    @TypeConverter
    public ArrayList<String> stringToArrayList(String json) {
        return GsonUtils.fromJson(json, ArrayList.class);
    }

}
